package com.eorchis.module.util;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

public class ExcelUtil {

	/**
	 * parame wbName	sheet名字
	 * */
	public static void initExcel(String wbName){
		HSSFWorkbook wb = new HSSFWorkbook();
		HSSFSheet sheet=wb.createSheet(wbName);
		HSSFRow row;
		HSSFCell cell;
	}
	
	/**
	 * parame wb workBook
	 * parame font	字体样式
	 * */
	public static HSSFCellStyle initCellStyle(HSSFWorkbook wb,HSSFFont font){
		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_LEFT); 
		style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		style.setFillForegroundColor(HSSFColor.WHITE.index);
		style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderBottom(HSSFCellStyle.BORDER_THIN); 
		style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
		style.setBorderTop(HSSFCellStyle.BORDER_THIN);
		style.setBorderRight(HSSFCellStyle.BORDER_THIN);
		if(font!=null){
			style.setFont(font);
		}
		return style;
	}
	
	/**
	 * parame wb workBook
	 * parame fontName 字体
	 * parame fontSize	字体大小
	 * */
	public static HSSFFont initCellFont(HSSFWorkbook wb,String fontName,int fontSize){
		HSSFFont font = wb.createFont();
		if(fontName!=null){
			font.setFontName(fontName);
		}
		if(fontSize!=0){
			font.setFontHeightInPoints((short) fontSize);
		}
		return font;
	}
}
